<?php
	
	class vL_var
	{
		private $tpl;
		
		public function __construct($tpl)
		{
			$this -> tpl = $tpl;
		}
		
		public function __set($var, $val)
		{
			$this -> tpl -> assign($var, $val);
		}
	}
	
    class viewLayer
        {
        		public static $var;
                private static $obj;
                private static $b;
                
                public static function setup($styleName)
                {
                        require_once './lib/opt/opt.class.php';
                        
                        if( !self::$obj )
                        {
                                self::$obj = new optClass;
                                self::$obj -> root = './view/'.$styleName.'/';
                                self::$obj -> compile = './view/temp/';
								self::$obj -> httpHeaders(OPT_HTML); 
								self::$obj -> registerPhpFunction('date', 'date');
								self::$obj -> registerPhpFunction('time', 'time');
								self::$obj -> registerPhpFunction('uc_words', 'capitalize');
								
                                self::$var = new vL_var(self::$obj);                        
						}
                }
                
                public static function render($page = NULL, $txt = NULL)
                {
                        if( $page )
                        {
                                self::$b .= self::$obj -> fetch($page.'.html');
                        }
                        else
                        {
                        		self::$obj -> assign('someShit', $txt);
                                self::$b .= self::$obj -> fetch('once.html');
	                    }
                       
                }
                
                public static function output()
                {
                		self::$var -> pageContent = self::$b;
						self::$var -> pageTitle = configParser::getData('servername');
                        self::$obj -> parse('index.html');
                }
        }
?>
